#pragma once

#include <gofcl_spi_r.h>

typedef struct {
	u16_s RBNE : 1;
	u16_s TBE : 1;
	u16_s I2SCH : 1;
	u16_s TXURERR : 1;
	u16_s CRCERR : 1;
	u16_s CONFERR : 1;
	u16_s RXORERR : 1;
	u16_s TRANS : 1;
	u16_s FERR : 1;
	u16_s : 7;
} spi_stat_s;

_Static_assert(sizeof(spi_stat_s) == 2, "Struct spi_stat_s defined error!");

static inline spi_stat_s spi_rreg_stat_s(spi_qe spi_q) {
	union {
		spi_stat_s s;
		u32_s u;
	} su = {
		.u = spi_rreg(spi_q, SPI_STAT_R),
	};
	return su.s;
}
